package com.cd2cd.code_template.controller;

import com.cd2cd.code_template.configuration.authority.AuthControl;
import com.cd2cd.code_template.configuration.constants.AuthTypeEnum;
import com.cd2cd.code_template.service.AuthConfigurationService;
import com.cd2cd.code_template.vo.BaseRes;
import com.cd2cd.code_template.vo.PageData;
import com.cd2cd.code_template.vo.SysAuthVo;
import java.util.List;
import javax.annotation.Resource;
import javax.annotation.Title;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("auth/configuration")
@AuthControl(name = "权限管理",type = AuthTypeEnum.SysAdmin,routePath = "/sys/menu")
public class AuthConfigurationController {

    @Resource
    private AuthConfigurationService authConfigurationService;

    /**
     * @gen_885_lwl
     * 权限列表
     * 权限列表
    **/
    @Title("权限列表")
    @ResponseBody
    @RequestMapping(value="list", method=RequestMethod.GET)
    public BaseRes<List<SysAuthVo>> getAuthList() {
        return authConfigurationService.getAuthList();
    }

    /**
     * @gen_886_lwl
     * 添加权限
     * 添加权限
     * @param sysAuthVo
    **/
    @Title("添加权限")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.POST)
    public BaseRes<String> addAuth(@RequestBody SysAuthVo sysAuthVo, BindingResult bindingResult) {
        return authConfigurationService.addAuth(sysAuthVo);
    }

    /**
     * @gen_887_lwl
     * 修改权限
     * 修改权限
     * @param sysAuthVo
    **/
    @Title("修改权限")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.PUT)
    public BaseRes<String> updateAuth(@RequestBody SysAuthVo sysAuthVo, BindingResult bindingResult) {
        return authConfigurationService.updateAuth(sysAuthVo);
    }

    /**
     * @gen_888_lwl
     * 删除权限
     * 删除权限
     * @param sysAuthVo
    **/
    @Title("删除权限")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.DELETE)
    public BaseRes<String> delAuth(@RequestBody SysAuthVo sysAuthVo, BindingResult bindingResult) {
        return authConfigurationService.delAuth(sysAuthVo);
    }

    /**
     * @gen_889_lwl
     * 权限详情
     * 权限详情
     * @param sysAuthVo
    **/
    @Title("权限详情")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.GET)
    public BaseRes<SysAuthVo> authInfo(SysAuthVo sysAuthVo) {
        return authConfigurationService.authInfo(sysAuthVo);
    }
}